package com.ruiyun.app.lib.jpush;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

import cn.jpush.android.api.JPushInterface;
import me.leolin.shortcutbadger.ShortcutBadger;

public class JPushInit {
    private static boolean isInit = false;
    private static JpushInterface jpushInterface;

    public static void init(Context context, boolean isDebug, JpushInterface myInterface) {
        isInit = true;
        if (TextUtils.isEmpty(JPushInterface.getRegistrationID(context))) {
            JPushInterface.setDebugMode(isDebug);    // 设置开启日志,发布时请关闭日志
            JPushInterface.init(context);            // 初始化 JPush
        }
        if (jpushInterface == null) {
            jpushInterface = myInterface;
        }
        Log.i("JPushInit", "极光初始化完成");
    }

    protected static void isStart(Context context, JpushMessage customMessage) {
        if(jpushInterface!=null){
            ShortcutBadger.applyCount(context, 0);
            jpushInterface.OnClick(context,customMessage);
        }
    }
    protected static void OnRegistrationChang(Context context, String customMessage) {
        if(jpushInterface!=null){
            jpushInterface.OnRegistrationChang(context,customMessage);
        }
    }
}
